# 使用 CentOS 作为基础镜像
FROM centos:centos7.4.1708

# 设置工作目录
WORKDIR /project

COPY http_conn/ ./http_conn/
COPY pool/ ./pool/
COPY locker/ ./locker/
COPY timer/ ./timer/
COPY log/ ./log/
COPY mysql_conn/ ./mysql_conn/
COPY resources/ ./resources/
COPY main.cpp makefile ./ 

RUN sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-Base.repo
RUN sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Base.repo
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
RUN yum clean all
RUN yum makecache

RUN yum -y --nogpgcheck install gcc gcc-c++ make cmake mysql-devel
RUN yum -y install epel-release --setopt=timeout=30 --setopt=retries=10
# RUN yum clean all
# RUN yum makecache
RUN yum -y --nogpgcheck install hiredis-devel --setopt=timeout=30 --setopt=retries=10
RUN yum -y --nogpgcheck install cryptopp-devel --setopt=timeout=30 --setopt=retries=10

RUN make
# RUN ulimit -n 65535

CMD ["/project/bin/webserver", "8888"]
